package hao.chen.mapper;

import hao.chen.entity.Student;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper // 程序启动时候, 自动生成接口的代理对象, 交给IOC容器进行管库
public interface StudentMapper {

    /**
     * 查询所学学生信息
     * @return
     */
    @Select("select * from student")
    List<Student> select();

    /**
     * 添加学生信息
     * @param student
     * @return
     */
    @Insert("insert into student(" +
            "id, name, no, gender, phone, id_card, degree, " +
            "graduation_date, create_time, update_time) " +
            "values(" +
            "#{id}, #{name}, #{no}, #{gender}, #{phone}, " +
            "#{idCard}, #{degree}, #{graduationDate}, " +
            "#{createTime}, #{updateTime})")
    Integer insert(Student student);


    /**
     * 修改学生信息
     * @param student
     * @return
     */
    @Update("update student set no=#{no}, phone=#{phone}, id_card=#{idCard} where id = #{id} ")
    Integer update(Student student);


    /**
     * 根据id查询学生信息
     * @param id
     * @return
     */
   Student selectId(Integer id);

   /**
     * 根据id删除学生信息
     * @param id
     * @return
     */
   Integer delete(Integer id);
}
